import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'login',
      component: () => import('../views/LoginView.vue'),
    },
    {
      path: '/main',
      name: 'main',
      component: () => import('../views/MainView.vue'),
      children: [
        {
          path: '/sale', name: 'sale',
          component: () => import('../views/Menu/SaleView.vue'),
        },
        {
          path: '/procurement',
          name: 'procurement',
          component: () => import('../views/Menu/ProcurementView.vue'),
          children: [
            {
              path: '/suppliers',
              name: 'suppliers',
              component: () => import('../views/Procurement/SuppliersModel.vue'),
            },
            {
              path: '/supplierstype',
              name: 'supplierstype',
              component: () => import('../views/Procurement/SuppliersType.vue'),
            },
            {
              path: '/supplierscount',
              name: 'supplierscount',
              component: () => import('../views/Procurement/SuppliersCount.vue'),
            },
          ]
        },
        {
          path: '/produce',
          name: 'produce',
          component: () => import('../views/Menu/ProduceView.vue'),
          children: [
            {
              path: '/Material',
              name: 'Material',
              component: () => import('../views/produce/Material.vue'),
            },
          ]
        },
        {
          path: '/inventory',
          name: 'inventory',
          component: () => import('../views/Menu/InventoryView.vue'),
          children: [
            {
              path: '/productshow',
              name: 'productshow',
              component: () => import('../views/Inventory/ProductShowView.vue'),
            },
            {
              path: '/typeshow',
              name: 'typeshow',
              component: () => import('../views/Inventory/TypeShowView.vue'),
            },
          ]
        },
        {
          path: '/finance',
          name: 'finance',
          component: () => import('../views/Menu/FinanceView.vue'),
          redirect: '/receivables',
          children: [
            {
              path: '/receivables',
              name: 'receivables',
              component: () => import('../views/Finance/ReceivablesView.vue'),
            },
            {
              path: '/payables',
              name: 'payables',
              component: () => import('../views/Finance/PayablesView.vue'),
            },
            {
              path: '/refunds',
              name: 'refunds',
              component: () => import('../views/Finance/RefundsView.vue'),
            }
          ]
        },
        {
          path: '/subscribe',
          name: 'subscribe',
          component: () => import('../views/Menu/SubscribeView.vue'),
          children: [
            {
              path: '/subscribelist',
              name: 'subscribelist',
              component: () => import('../views/Subscribe/SubscribeListView.vue'),
            },
          ]
        },
        {
          path: '/staff',
          name: 'staff',
          component: () => import('../views/Menu/StaffView.vue'),
          children: [
            {
              path: '/stafflist',
              name: 'stafflist',
              component: () => import('../views/Staff/StaffListView.vue'),
            },
          ]
        },
      ]
    },
  ],
})

export default router
